<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title> <c:if test="${type==0||type==null}">销售订单</c:if><c:if test="${type==0||type==null}">销售订单</c:if><c:if test="${type==1}">财务审核</c:if><c:if test="${type==2}">生产审核</c:if></title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript" src="${ctx}/js/jsp/xxkj/logic/sales.js"></script>
	<script type="text/javascript">
	var type ="${type}";
	var basic_Url="${ctx}/logic/sales";
	var basic_WUrl="logic/sales";
	var basic_Title="销售订单";
	var show_Width=880;
	var show_Hight=500;
	$(function(){
		if(type==0||type==""){
			basic_Title="销售订单";
		}
		if(type==1){
			basic_Title="财务审核";
		}
		if(type==2){
			basic_Title="生产审核";
		}
	});
		
		function createSearch(){
			init(1,8,'100,100,100,100,100,100,100,100','10%');
			//第一行的数据
			addCommon(0,0,"lable","销售单号：");
			addCommon(0,1,"txtlike","zd001FormCode");
			addCommon(0,2,"lable","客户单位名称：");
			addCommon(0,3,"txtlike","zd006CustomerName");
			addCommon(0,4,"lable","制单人：");
			addCommon(0,5,"txtlike","bizCreatorName");
			addCommon(0,6,"lable","PI编号：");
			addCommon(0,7,"txtlike","zd002PiCode");
		}
		
		function searchAP(){
			multipleSearch("#table1",true,"",basic_Url+"/list.do?type=${type}");
		}
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		}  
		/*
		 * 删除订单
		 */ 
		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			if (rows==null || 0== rows.length){
				$.dialog.alert('请选择需要操作删除的行！');
				return;
			}
			var canDel = true;
			$(rows).each(function() {
				if (!(this.zd024Billstatus=="PCSR_SAVE"||this.zd024Billstatus=="PCSR_BACK" )){
					canDel = false;
					$.dialog.alert('您删除的单据中,存在不能删除操作的单据状态！');
				}
				
				if(this.bizCreatorName !='${user.name}'){
					canDel = false;
					$.dialog.alert('您删除的单据中,存在非本人的单据，不能删除操作!');
				}
			});
			
			if(canDel){
				del();//ajax 删除
			}
			
		}
		
		//添加
		function addtype(){
			var url = basic_WUrl+"/operate/add/0.do?type=${type}";
			
			ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
		}
		
		//编辑
		function edittype(data){
			var url = basic_WUrl+"/operate/edit/"+data.id+".do?type=${type}";
			ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
		}
	</script>
	
  </head>
 <body style="padding:10px" onload="createSearch()">  
       <div id="layout1">
          <div class="panelBar">
	            <ul class="toolBar">
		           <c:if test="${type==0||type==null}">
		            <li><a class="add" onclick="addtype()"><span>新增</span></a></li>
				   <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
				   </c:if>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
<!--    </div> -->
    </body>
</html>